<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>管理员登录</title>  
    <link rel="shortcut icon" type="image/x-icon" href="${pageContext.request.contextPath }/images/icon.ico" media="screen" /> 
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/pintuer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css">
    <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
    <script src="${pageContext.request.contextPath}/js/pintuer.js"></script>
    <!-- 弹框的相关文件 -->
	<link href="${pageContext.request.contextPath}/css/addAlertCss/main.css" rel="stylesheet" type="text/css"/>
	<script src="${pageContext.request.contextPath}/js/addAlertJs/qikoo.js"></script>
</head>
<body>
<div class="bg"></div>
<div class="container">
    <div class="line bouncein">
        <div class="xs6 xm4 xs3-move xm4-move">
            <div style="height:150px;"></div>
            <div class="media media-y margin-big-bottom">           
            </div>         
            <form id="loginForm" action="${pageContext.request.contextPath}/index.html" method="post" target="_parent">
            <div class="panel loginbox">
                <div class="text-center margin-big padding-big-top"><h1>统一电子印章管理平台</h1></div>
           		<div align="center">国家烟草专卖局</div>
                <div class="panel-body" style="padding:30px; padding-bottom:10px; padding-top:10px;">
                	<span style="color:red">${errorMsg }  </span>
                    <div class="form-group">
                        <div class="field field-icon-right">
                            <input type="text" class="input input-big" name="phone" id="phone" placeholder="登录账号" data-validate="required:请填写手机号" />
                            <span class="icon icon-user margin-small"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="field field-icon-right">
                            <input type="password" class="input input-big" name="psw" id="psw" placeholder="登录密码" data-validate="required:请填写验证码" />
                            <span class="icon icon-key margin-small"></span>
                        </div>
                    </div>
                </div>
                <div style="padding:10px;">
                    <input type="button" class="button button-block bg-main text-big input-big" value="登录" onclick="toSubmit()">
                </div>
            </div>
            </form>          
        </div>
    </div>
</div>

</body>
<script type="text/javascript">
    //	检验手机号是否为11位且全为数字
    function checkEmpPhoneNum(a) {

        if(a.length != 11 || isNaN(a)){
            return false;
        }else{
            return true;
        }

    }
    function mySubmit(flag){
        return flag;
    }
    function toSubmit(){
        const formData = new FormData();
        formData.append("phone",$("#phone").val());
        formData.append("psw",$("#psw").val());

        $.ajax({
            type: "post",
            url: "${pageContext.request.contextPath}/login.html",
            data: formData,
            cache: false,
            processData: false,
            contentType: false,
            success: function (data)
            {
                //成功后返回一个随机数
                //对其进行签名



            }
        });


        // 船检局版本因为单位管理员的账号不止是手机号，所以去掉该判断
        if(!checkEmpPhoneNum(phone)){
            qikoo.dialog.alert("手机号格式错误！请正确输入！");
            return mySubmit(false);
        }else{
            document.getElementById("loginForm").submit();
        }
    }




</script>
</html>